#include "SQLInSubQueryExpr.h"
#include "../../visitor/SQLASTVisitor.h"

SQLInSubQueryExpr::SQLInSubQueryExpr() : xnot(BOOL::FALSE)
{
}

SQLInSubQueryExpr::~SQLInSubQueryExpr()
{
  // if (expr != NULL)
  // {

  //   delete expr;
  //   expr = NULL;
  // }
}
BOOL_ptr SQLInSubQueryExpr::isNot()
{
  return xnot;
}

void SQLInSubQueryExpr::setNot(BOOL_ptr theNot)
{
  xnot = theNot;
}

SQLExpr_ptr SQLInSubQueryExpr::getExpr()
{
  return expr;
}

void SQLInSubQueryExpr::setExpr(SQLExpr_ptr theExpr)
{
  expr = theExpr;
}

SQLInSubQueryExpr::SQLInSubQueryExpr(SQLSelect_ptr theSelect) : subQuery(theSelect), xnot(BOOL::FALSE)
{

  // subQuery = theSelect;
}

SQLSelect_ptr SQLInSubQueryExpr::getSubQuery()
{
  return subQuery;
}

void SQLInSubQueryExpr::setSubQuery(SQLSelect_ptr theSubQuery)
{
  if (theSubQuery != NULL)
  {
    theSubQuery->setParent(SharedObject(SQLInSubQueryExpr));
  }
  subQuery = theSubQuery;
}

void SQLInSubQueryExpr::output(std::stringstream * buf)
{
  subQuery->output(buf);
}

void SQLInSubQueryExpr::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLInSubQueryExpr)))
  {
    acceptChild(visitor, expr);
    acceptChild(visitor, (subQuery));
  }

  visitor->endVisit(SharedObject(SQLInSubQueryExpr));
}

// int SQLInSubQueryExpr::hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((expr == NULL) ? 0 : expr.hashCode());
// result = prime * result + (xnot ? 1231 : 1237);
// result = prime * result + ((subQuery == NULL) ? 0 : subQuery.hashCode());
// return result;
//}

// BOOL_ptr SQLInSubQueryExpr::equals(Object obj) {
// if (this == obj) {
// return BOOL::TRUE;
//}
// if (obj == NULL) {
// return BOOL::FALSE;
//}
// if (getClass() != obj.getClass()) {
// return BOOL::FALSE;
//}
// SQLInSubQueryExpr other = (SQLInSubQueryExpr) obj;
// if (expr == NULL) {
// if (other.expr != NULL) {
// return BOOL::FALSE;
//}
//} else if (!expr.equals(other.expr)) {
// return BOOL::FALSE;
//}
// if (xnot != other.xnot) {
// return BOOL::FALSE;
//}
// if (subQuery == NULL) {
// if (other.subQuery != NULL) {
// return BOOL::FALSE;
//}
//} else if (!subQuery.equals(other.subQuery)) {
// return BOOL::FALSE;
//}
// return BOOL::TRUE;
//}

 BOOL_ptr SQLInSubQueryExpr::isGlobal() {
        return global;
    }

 void SQLInSubQueryExpr::setGlobal(BOOL_ptr global) {
        this->global = global;
    }